#!/usr/bin/python
#-*- coding: utf-8 -*-

import MySQLdb as mdb
import sys

con = mdb.connect("localhost","root", "root", "test")

with con:
    cur = con.cursor()
    #cur.execute("INSERT INTO student(name, `from`, title) VALUES('ADF','ASF','ASF')")
    #cur.execute("INSERT INTO student(name, `from`, title) VALUES('123DF','A123SF','32ASF')")
    cur.execute("SELECT * FROM student")
    numrows = int(cur.rowcount)
    for i in range(numrows):
        row = cur.fetchone()
        print row[0], row[1], row[2], row[3]


with con:
    cur = con.cursor()
    cur.execute("SELECT * FROM student")

    rows = cur.fetchall()
    print rows
    for row in rows:
        print "%s, %s, %s" % (row[0], row[1], row[2])

    
    
